<template>
  <view class="view">
    <view data-test="test" class="test">test view</view>
    <text class="res">res: {{ JSON.stringify(res, null, 2) }}</text>
    <button id="button" @click="createSelectorQuery">
      createSelectorQuery
    </button>
  </view>
</template>

<script>
export default {
  data () {
    return {
      res: {}
    }
  },
  methods: {
    async createSelectorQuery () {
      return new Promise((resolve, reject) => {
        uni.createSelectorQuery().in(this).select('.test').fields({
          dataset: true,
          size: true,
          scrollOffset: true,
          properties: ['scrollX', 'scrollY'],
          computedStyle: ['height', 'margin', 'backgroundColor'],
        }, (res) => {
          console.log(res)
          this.res = res
          resolve(res)
        }).exec()
      })
    }
  }
}
</script>

<style>
.test {
  font-size: 16px;
  line-height: 40px;
  width: 100px;
  background-color: #cccccc;
}
</style>